﻿
; (function () {
    var backflag = $('.backflag').val();
    var dataIfo = $('#dataIfo').val();
    if (dataIfo) { dataIfo = JSON.parse(dataIfo) }
    var chosePlacerorderno = Number($('#chosePlacerorderno').val());
    var page = {
        name: '',
        relativeUrl: '',
        pregnantDays: 0,//孕周
        finishList: [],
        unFinishList: [],
        printTotal: 0,
        recommendInfo: {},//推荐的预约信息
        timesPageNum: 0,
        dateIndex: 0,
        editSchedule: true,
        scheduleExamRequest: '',
        //页面初始化
        init: function () {
            var searchBar = $('#searchBar').height()+20;
            if (isNaN(searchBar)) {
                $('#mainContain').height($(window).height() - 100);
                $('.technology_list_container').height($(window).height() - 450 - $('.technology_right_first').height());
            } else { 
                $('#mainContain').height($(window).height() - 100 - searchBar);
                $('.technology_list_container').height($(window).height() - 450 - $('.technology_right_first').height() - searchBar); 
            }
            page.relativeUrl = $('#hdnRelativeUrl').val();
            var scheduleType = '';
            if (backflag == '_OutPatientPartial') {
                scheduleType = 'OutPatient'
            } else if (backflag == 'InPatient') {
                scheduleType = 'InPatient'
            } else {
                scheduleType = 'Technology';
            }
            page.schedule = new Schedule(scheduleType, page.relativeUrl);
            page.schedule.days = 7;
            if (dataIfo) {
                page.getExamRequestListCallback(dataIfo)
            } else {
                page.schedule.getExamRequestScheduleInfoList(page.getExamRequestListCallback);
            }
            page.finishList.current = 0;
            page.unFinishList.current = 0;
            pageEvent.init();
            if (backflag) {
                $('#backTo').show();
            }
        },

        //获取申请单列表+1
        getExamRequestListCallback: function (data) {
            page.schedule.examRequestList = data;
            $('#mainContain .finish-container').html("");
            $('#mainContain .un-finish-container').html("");
            page.name = data[0].Name;
            $('.name').text(page.name);
            $('.sex').text(data[0].Sex);
            $('.age').text(data[0].Age + data[0].AgeUnit);
            $('.department').text(data[0].RequestDeptName);
            $('.phone').text(data[0].ContactPhoneNO);
            for (var i = 0; i < data.length; i++) {
                if (data[i].ScheduleStatus==0) {
                    page.finishList.push(data[i]);
                    page.bindFinish(data[i], page.finishList.length);
                } else {
                    page.unFinishList.push(data[i]);
                    page.bindUnFinish(data[i], page.unFinishList.length);
                }
            }

            $('.booknum').text('（' + page.finishList.length + '）');
            $('.unbooknum').text('（' + page.unFinishList.length + '）');
            page.schedule.showPregnantDays();
        },

        //未预约+1
        bindUnFinish: function (exam, i) {
            if (!exam) {
                return;
            }
            var startDate = imcis.convertDateFromJson(exam.ScheduleStartDate);
            var endDate = imcis.convertDateFromJson(exam.ScheduleEndDate);
            var scheduleTime = startDate.substr(11, 5) + "-" + endDate.substr(11, 5);
            var date = startDate.substr(0, 11);
            var isFinsh_items_active = '';
            if (chosePlacerorderno == exam.PlacerOrderNO) { isFinsh_items_active = 'isFinsh_items_active'; }
            var temp = '<div class="isFinsh_items ifbook_items  ' + isFinsh_items_active + '" data-placerorderno=' + exam.PlacerOrderNO + '>' +
                       ' <div class="isFinsh_time ">' +
                            ' <input type="checkbox" name="check" class="check check_click">' +
                            ' <span class="check_click">' + exam.ServiceSectID + '' +exam.ProcedureName+'</span>' +
                       ' </div>' +
                        '<div class="isfinish_detail">' +
                            '<span>' + date + ' ' + scheduleTime + '</span>' +
                       ' </div>' +
                        '<div class="isfinish_detail">' +
                           ' <span>地点:</span>' +
                             '<span>' + exam.ScheduleResourceName + "-" + exam.ObservationLocation + '</span>' +
                        '</div>' +
                   ' </div>';
            $('#mainContain .un-finish-container').append(temp);
            $('.un-finish-container').css({ 'max-height': ($(window).height() - 320) / 2 });
            if (chosePlacerorderno) {
                pageEvent.startSchedule(chosePlacerorderno);
                page.chosePlacerorderno = "";
            }
         
        },

        //已预约+1
        bindFinish: function (exam, i) {
            if (!exam) {
                return;
            }
            var startDate = imcis.convertDateFromJson(exam.ScheduleStartDate);
            var endDate = imcis.convertDateFromJson(exam.ScheduleEndDate);
            var scheduleTime = startDate.substr(0, 16) + "-" + endDate.substr(11, 5);
            var isFinsh_items_active = '';
            if (chosePlacerorderno == exam.PlacerOrderNO) { isFinsh_items_active = 'isFinsh_items_active'; }
            var temp = '<div class="isFinsh_items ifbook_items ' + isFinsh_items_active + '" data-placerorderno=' + exam.PlacerOrderNO + '>' +
                       ' <div class="isFinsh_time">' +
                            ' <input type="checkbox" name="check" class="check check_click">' +
                            ' <span class="check_click">' + exam.ServiceSectID + exam.ProcedureName + '</span>' +
                            ' <span class="cancel_book">取消</span>' +
                       ' </div>' +
                        '<div class="isfinish_detail">' +
                            '<span>' + scheduleTime + '</span>' +
                       ' </div>' +
                        '<div class="isfinish_detail">' +
                           ' <span>地点:</span>' +
                             '<span>' + exam.ScheduleResourceName + "-" + exam.ObservationLocation + '</span>' +
                        '</div>' +
                   ' </div>';

            $('#mainContain .finish-container').append(temp);
            $('.finish-container ').height(($(window).height() - $('#unFinishContainer').height() - 300));
            if (chosePlacerorderno) {
                pageEvent.editSchedule(chosePlacerorderno);
                page.chosePlacerorderno = "";
            }
        }
    };

    var pageEvent = {
        //事件初始化
        init: function () { 
            //取消预约+2
            $('#mainContain').on('click', '.cancel_book', pageEvent.cancelSchedule);
            //修改预约时间+2
            $('.finish-container').on('click', '.isfinish_detail',  pageEvent.editSchedule);
            //未预约开始预约+2
            $('#mainContain').on('click', '.isFinsh_items',pageEvent.startSchedule);

            //一键预约多个检查申请
            $('#saveMulti').on('click', function () {
                page.schedule.comfirm('是否一键预约保存', function () {
                    pageEvent.saveMultiExamSchedule();
                });
             
            });
            //保存预约+1
            $('#save_time').on('click', pageEvent.saveExamSchedule);

            //切换日期+2
            $('.technology_week').on('click', '.day_items', pageEvent.changeDate);
            //切换时间组
            $('.ampm_container').on('click', '.ampm', pageEvent.changeGroup);
            //选中时间+2
            $('#time_detail_container').on('click', '.schedule-enable', pageEvent.selectTime);
            //选中打印的条数
            $('.finish-container').on('click', '.check_name, .check_detail ', pageEvent.selectPrint);
            //打印
            $('#print').on('click', pageEvent.print);
            //时间修改
            layui.use('laydate', function () {
                var laydate = layui.laydate;
                var start = {
                    min: laydate.now()
                  , max: '2099-06-16 23:59:59'
                  , istoday: false
                  , choose: function (datas) {
                      pageEvent.getSingleExamScheduleArrange(page.scheduleExamRequest, datas);
                  }
                };
                document.getElementById('date').onclick = function () {
                    start.elem = this;
                    laydate(start);
                }

            });
            //选中某一条数据
            $(".technology_left").on('click', '.check_click', function () {
                var $this = $(this).closest('.isFinsh_time').find('.check');
                var print = $this.closest('.is_finish').find('#print');
                var isChecked = $this.prop('checked');
                var print_num = Number($('#print .print_num').text());
                if (isChecked) {
                    if (print.length) {
                        $('#print .print_num').text(print_num + 1);
                    }
                    $this.addClass('checked_bg');
                } else {
                    if (print.length) {
                        if (print_num >= 1) { $('#print .print_num').text(print_num - 1); } else { $('#print .print_num').text(0); }
                    }
                    $this.removeClass('checked_bg')
                }
            });
            //返回
            $('#backTo').click(function () {
                pageEvent.backTo(backflag);
            })
        },
        //返回
        backTo: function (backflag) {
            $('.technology_container').hide();
            $('#outPatientMain').show();
            $('.patient_main').show();

        },
        //取消预约+2
        cancelSchedule: function ($this) {
            page.schedule.comfirm('是否一键预约保存', function () {
                var placerOrderNO = $this.closest('.ifbook_items').data("placerorderno");
                var exam = null, index = 0;
                $.each(page.finishList, function (i, n) {
                    if (n.PlacerOrderNO == placerOrderNO) {
                        exam = n;
                        index = i;
                        return false;
                    }
                });

                page.schedule.cancelSchedule({
                    'PlacerOrderNO': placerOrderNO
                }, function (data) {
                    if (exam.printFlag) {
                        exam.printFlag = false;
                        page.printTotal--;
                        $('#print').text('打印' + (page.printTotal <= 0 ? "" : "（" + page.printTotal + "）"));
                    }

                    page.unFinishList.push(exam);
                    page.finishList.splice(index, 1);

                    $('.booknum').text('（' + page.finishList.length + '）');
                    $('.unbooknum').text('（' + page.unFinishList.length + '）');
                });
            });
        },

        //修改预约时
        editSchedule: function (chosePlacerorderno) {
            $('.technology_right').show();
            var ifbook_itemsarr = $('.ifbook_items');
            $.each(ifbook_itemsarr, function (i) {
                ifbook_itemsarr.eq(i).removeClass('isFinsh_items_active');
            })
            $(this).closest('.ifbook_items').addClass('isFinsh_items_active');
            page.editSchedule = true;
            var placerOrderNO = '';
            if (!isNaN(chosePlacerorderno)) { placerOrderNO = chosePlacerorderno } else {
                placerOrderNO = $(this).closest('.ifbook_items').data('placerorderno');
            }
            $.each(page.finishList, function (i, n) {
                if (n.PlacerOrderNO == placerOrderNO) {
                    n.printFlag = !n.printFlag;
                    page.scheduleExamRequest = n;
                    return false;
                }
            });
            page.schedule.getScheduleInfo(page.scheduleExamRequest, [], "", "", pageEvent.getScheduleInfoCallback);

            $('.ServiceSectID').text(page.scheduleExamRequest.ServiceSectID);
            $('.ProcedureName').text(page.scheduleExamRequest.ProcedureName);
            $('.ClinicDiagnosis').text(page.scheduleExamRequest.ClinicDiagnosis);
            $('.RelevantClinicalInfo').text(page.scheduleExamRequest.RelevantClinicalInfo);
        },

        //开始预约
        startSchedule: function (chosePlacerorderno) {
            $('.technology_right').show();
            var ifbook_itemsarr = $('.ifbook_items');
            $.each(ifbook_itemsarr, function (i) {
                ifbook_itemsarr.eq(i).removeClass('isFinsh_items_active');
            });
            $(this).closest('.ifbook_items').addClass('isFinsh_items_active');
            var placerOrderNO = '';
            if (!isNaN(chosePlacerorderno)) { placerOrderNO = chosePlacerorderno } else {
                placerOrderNO = $(this).closest('.ifbook_items').data('placerorderno');
            } 
            page.editSchedule = false;
            $.each(page.unFinishList, function (i, n) {
                if (n.PlacerOrderNO == placerOrderNO) {
                    n.printFlag = !n.printFlag;
                    page.scheduleExamRequest = n;
                    return false;
                }
            });
            page.schedule.getScheduleInfo(page.scheduleExamRequest, [], "", "", pageEvent.getScheduleInfoCallback);

            $('.ServiceSectID').text(page.scheduleExamRequest.ServiceSectID);
            $('.ProcedureName').text(page.scheduleExamRequest.ProcedureName);
            $('.ClinicDiagnosis').text(page.scheduleExamRequest.ClinicDiagnosis);
            $('.RelevantClinicalInfo').text(page.scheduleExamRequest.RelevantClinicalInfo);
        },

        //保存单个预约
        saveExamSchedule: function () {
            page.schedule.saveExamSchedule(null, function (data) {
                page.schedule.getExamRequestScheduleInfoList(page.getExamRequestListCallback);
            });
        },

        //一键预约多个检查申请
        saveMultiExamSchedule: function () {
            var choseFishList = [];
            var checkArr = $('.un-finish-container .check');
            $.each(checkArr, function (i) {
                if (checkArr.eq(i).prop('checked')) {
                    var PlacerOrderNO = checkArr.eq(i).closest('.ifbook_items').data('placerorderno');
                    $.each(page.unFinishList, function (j) {
                        if (PlacerOrderNO == page.unFinishList[j].PlacerOrderNO) {
                            choseFishList.push(page.unFinishList[j])
                        } else {
                        }
                    })
                }
            });
            imcis.ajax(page.relativeUrl + 'SaveMultiExamSchedule', choseFishList, true, function (data) {

                if (data && data.success) {
                    var errorMsg = "";
                    for (var i = 0; i < data.resultList.length; i++) {
                        if (data.resultList[i].ErrorMsg) {
                            errorMsg += data.resultList[i].ErrorMsg;
                        } else {
                            var exam = null, index = 0;
                            $.each(choseFishList, function (idx, n) {
                                if (n.PlacerOrderNO == data.resultList[i].pagepage) {
                                    exam = n;
                                    index = idx;
                                    return false;
                                }
                            });

                            exam.ScheduleID = data.resultList[i].ScheduleResultInfo.ScheduleID;
                            exam.ScheduleResourceUID = data.resultList[i].ScheduleResultInfo.ScheduleResourceUID;
                            exam.ScheduleResourceName = data.resultList[i].ScheduleResultInfo.ScheduleResourceName;
                            exam.ScheduleStartDate = data.resultList[i].ScheduleResultInfo.ScheduleStartDate;
                            exam.ScheduleEndDate = data.resultList[i].ScheduleResultInfo.ScheduleEndDate;
                            exam.ScheduleNotice = data.resultList[i].ScheduleResultInfo.ScheduleNotice;
                            exam.printFlag = false;
                            page.finishList.push(exam);
                            page.unFinishList.splice(index, 1);
                        }
                    }

                    pageEvent.bindAfterSave();

                    if (errorMsg) {
                        page.schedule.alert(errorMsg);
                    }
                } else {
                    page.schedule.alert("一键预约失败，请重试!");
                }
            });
        },

        //获取单个申请的预约资源排班+1
        getScheduleInfoCallback: function (data) {
            page.currentRecommend = {};
            page.currentRecommend.Quantity = data.Quantity;
            page.currentRecommend.ResourceName = data.ResourceName;
            page.currentRecommend.ResourceUID = data.ResourceUID;
            page.currentRecommend.ScheduleDate = data.ScheduleDate;
            page.currentRecommend.ScheduleTime = data.ScheduleTime;
            page.currentRecommend.ScheduleArrangeList = [];

            $.each(data.ScheduleArrangeResourceInfoList, function (i, n) {
                if (n.ResourceUID == data.ResourceUID) {
                    $('#time_container .day_items').removeClass('actived_item');
                    $('#time_container .day_0').addClass('actived_item');

                    page.currentRecommend.ObservationLocation = n.ResourceLocation;
                    $('.day_0').addClass('active_week');
                    for (var j = 0; j < n.ScheduleArrangeDateInfoList.length; j++) {
                        var arrangeDay = imcis.convertDateFromJson(n.ScheduleArrangeDateInfoList[j].ArrangeDay, true);
                        $('.day_' + j + ' .myd').text(arrangeDay);

                        var scheduleArrange = { groupList: [] };
                        var timeList = n.ScheduleArrangeDateInfoList[j].ScheduleArrangeTimeInfoList;
                        for (var i = 0; i < timeList.length; i++) {
                            if (!scheduleArrange[timeList[i].GroupName]) {
                                scheduleArrange[timeList[i].GroupName] = {
                                    times: []
                                };
                                scheduleArrange.groupList.push(timeList[i].GroupName);
                            }

                            scheduleArrange[timeList[i].GroupName].times.push(timeList[i]);

                            if (page.currentRecommend.ScheduleDate == arrangeDay
                                && page.currentRecommend.ScheduleTime == timeList[i].StartTime + "-" + timeList[i].EndTime) {
                                scheduleArrange.scheduleGroupName = timeList[i].GroupName;
                            }
                        }

                        page.currentRecommend.ScheduleArrangeList.push(scheduleArrange);

                        var arrangeWeek = '';
                        switch (n.ScheduleArrangeDateInfoList[j].ArrangeWeek) {
                            case 7:
                                arrangeWeek = "周日";
                                break;
                            case 1:
                                arrangeWeek = "周一";
                                break;
                            case 2:
                                arrangeWeek = "周二";
                                break;
                            case 3:
                                arrangeWeek = "周三";
                                break;
                            case 4:
                                arrangeWeek = "周四";
                                break;
                            case 5:
                                arrangeWeek = "周五";
                                break;
                            case 6:
                                arrangeWeek = "周六";
                                break;
                        }
                        $('.day_' + j + ' .week').text(arrangeWeek);
                    }
                }
            });

            pageEvent.addDateGroup(page.currentRecommend.ScheduleArrangeList[0]);
            $('.right_add').html(page.currentRecommend.ResourceName);
        },

        //添加日期下的时间组+2
        addDateGroup: function (scheduleArrange) {
            $('.ampm_title').html('');
            if (scheduleArrange.groupList.length > 1) {
                for (var i = 0; i < scheduleArrange.groupList.length; i++) {

                    var html = '';
                    var border_left = "";
                    if (i == 0) { border_left = 'border_left' } else { border_left = '' }
                    if (scheduleArrange.scheduleGroupName === scheduleArrange.groupList[i]) {

                        html = '<li class="border_left ampm_active ampm" data-groupname="' + scheduleArrange.groupList[i] + '" >' +
                                    '<span>' + scheduleArrange.groupList[i] + '</span>' +
                                '</li>';
                    } else {
                        html = '<li class=" border_left ampm" data-groupname="' + scheduleArrange.groupList[i] + '" >' +
                                    '<span>' + scheduleArrange.groupList[i] + '</span>' +
                                '</li>';
                    }
                    $(' .ampm_title').append(html);
                }
            }
            //时间段
            pageEvent.addGroupTime(scheduleArrange, scheduleArrange.scheduleGroupName)
        },
        //时间组添加时间段+2
        addGroupTime: function (scheduleArrange, groupName, page) {
            if (scheduleArrange[groupName]) {
                var times = scheduleArrange[groupName].times;;
                var totalStr = '';
                var addTdStr = '';
                if (times.length % 7 == 0) { times = scheduleArrange[groupName].times; } else {
                    var i = 7 - ((times.length) % 7);
                    for (var j = 0; j < i; j++) {
                        addTdStr += '<td  class="schedule-banlk " style=" width: 14.28%;"></td>'
                    }
                    addTdStr += '</tr>';
                }
                for (var i = 0; i < times.length ; i++) {
                    var temp = '';
                    var time = times[i].StartTime + "-" + times[i].EndTime;
                    switch (times[i].ScheduleTimeStatus) {
                        case 3:
                        case 4:
                            //不可预约时间           
                            temp += '<td class="schedule-disable" data-uid="' + times[i].TimeDetailUID + '" data-quantity="' + times[i].Quantity + '" >' + time + '</td>';
                            break;
                        case 0://选中的时间
                            temp += '<td class="schedule-current" data-uid="' + times[i].TimeDetailUID + '" data-quantity="' + times[i].Quantity + '" >' + time + '</td>';
                            break;
                        case 1:
                            //选中的时间
                            temp += '<td class="schedule-finish" data-uid="' + times[i].TimeDetailUID + '" data-quantity="' + times[i].Quantity + '" >' + time + '</td>';
                            break;
                        default:
                            //可预约时间
                            temp += '<td class=" schedule-enable" data-uid="' + times[i].TimeDetailUID + '" data-quantity="' + times[i].Quantity + '" >' + time + '</td>';
                            break;
                    }

                    if (i == 0 || i % 7 == 0) {
                        totalStr = totalStr + '<tr>' + temp;
                    } else if ((i + 1) % 7 == 0) {
                        totalStr = totalStr + temp + '</tr>'
                        temp = '';
                    } else {
                        totalStr = totalStr + temp;
                    }
                }
                if (totalStr == '') {
                    var ampmarr = $('.ampm');
                    $.each(ampmarr, function (i) {
                        ampmarr.eq(i).addClass('border_bottom');
                    })
                } else {
                    var ampmarr = $('.ampm');
                    $.each(ampmarr, function (i) {
                        ampmarr.eq(i).removeClass('border_bottom');
                    })

                }
                $('#time_detail_container').html(totalStr + addTdStr);


            }
        },

        //切换时间组+2
        changeGroup: function () {
            var ampmArr = $('.ampm_title  .ampm');
            $.each(ampmArr, function (i) {
                ampmArr.eq(i).removeClass('ampm_active');
            });
            $(this).addClass('ampm_active');
            var scheduleArrange = page.currentRecommend.ScheduleArrangeList[page.dateIndex];
            page.timesPageNum = 0;
            pageEvent.addGroupTime(scheduleArrange, $(this).data("groupname"), page.timesPageNum);
           
        },

        //选中时间+1
        selectTime: function () {
            if ($(this).hasClass('schedule-enable')) {
                $('#time_detail_container .schedule-current').removeClass('schedule-current').addClass('schedule-enable');
                $(this).removeClass('schedule-enable').addClass('schedule-current');

                page.currentRecommend.ScheduleTime = $(this).text();
                page.currentRecommend.Quantity = $(this).data('quantity');
                page.scheduleExamRequest.ChangeFlag = true;
            }
        },

        //切换日期
        changeDate: function () {
            var loading = layer.load(1, { shade: [0.4, '#333'] });//加载层
            var day_itemsArr = $('.technology_week .day_items');
            $.each(day_itemsArr, function (i) {
                day_itemsArr.eq(i).removeClass('active_week');
            })
            var $this = $(this).addClass('active_week');
            page.dateIndex = $(this).data("i");
            var date = $this.find('.myd').text();
            page.currentRecommend.scheduleDate = date;
            var scheduleArrange = page.currentRecommend.ScheduleArrangeList[page.dateIndex];
            var now = new Date();
            var isGroupName = false;
            if (date == now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()) {
                now = new Date(date + " " + now.getHours() + ":" + now.getMinutes());
                for (var i = 0; i < scheduleArrange.groupList.length; i++) {
                    var times = scheduleArrange[scheduleArrange.groupList[i]].times;

                    for (var j = 0; j < times.length; j++) {
                        var start = new Date(date + " " + times[j].StartTime);
                        var end = new Date(date + " " + times[j].EndTime);

                        if (now >= start && now <= end) {
                            scheduleArrange.scheduleGroupName = times[j].GroupName;
                            isGroupName = true;
                            break;
                        }
                    }

                    if (isGroupName) {
                        break;
                    }
                }
            }
            if (!isGroupName) {
                scheduleArrange.scheduleGroupName = scheduleArrange.groupList[0];
            }
            var placerOrderNO = page.scheduleExamRequest.PlacerOrderNO; 
            pageEvent.addDateGroup(scheduleArrange);
            layer.close(loading);
        },

        //选择要打印的项
        selectPrint: function () {
            var placerOrderNO = $(this).closest('.ifbook_items').data('placerorderno');
            var printExam = null;
            $.each(page.finishList, function (i, n) {
                if (n.PlacerOrderNO == placerOrderNO) {
                    n.printFlag = !n.printFlag;
                    printExam = n;
                    return false;
                }
            });

            if (printExam.printFlag) {
                page.printTotal++;
            } else {
                page.printTotal--;
            }
        },

        //打印
        print: function () {
            var printNum = 0;
            $.each(page.finishList, function (i, n) {
                if (n.printFlag) {
                    printNum++;
                    setTimeout(function () {
                        page.schedule.print(n);
                    }, 2000);
                }
            });

            if (printNum == 0) {
                page.schedule.alert('请选择要打印的预约。');
            }
        },

        //未预约的保存后重新绑定+2
        bindAfterSave: function () {
            $('.unbooknum').text('（' + page.unFinishList.length + '）');
            $('.booknum').text('（' + page.finishList.length + '）');
            $('.finish-container').html('');
            for (var i = 0 ; i < page.finishList.length; i++) {
                page.bindFinish(page.finishList[i], i + 1);
            }
            $('.un-finish-container').html('');
            for (var i = 0 ; i < page.unFinishList.length; i++) {
                page.bindUnFinish(page.unFinishList[i], i + 1);
            }

        }
    };


    page.init();
})()
